﻿@extends('layout.base')
@extends('layout')
@section('content')
@section('contenido')
@stop
<style> 
.modal-header-default {
  color:#fff;
    padding:9px 15px;
    border-bottom:1px solid #eee;
    background-color: #009966;
    -webkit-border-top-left-radius: 5px;
    -webkit-border-top-right-radius: 5px;
    -moz-border-radius-topleft: 5px;
    -moz-border-radius-topright: 5px;
     border-top-left-radius: 5px;
     border-top-right-radius: 5px;
}

</style>

<div class="panel panel-success">
      <div class="panel-heading">
      <h3><left><a href = "#"><img src="./images/potreros.png" height="75px" width="75px"></a></left>Lista de potreros</h3>
      </div>
    </div>

<div class="panel panel-success">
<div class="input-group"> <span class="input-group-addon "><span class="glyphicon glyphicon-search"></span> Buscar</span>

    <input name="filter" id="filter" type="text" class="form-control" placeholder="¿Qué desea buscar?"></div>    

        <table id="potreros" class="table table-striped table-hover display display nowrap">

        <thead>
          <tr>
            <th>Id</th>
            <th>Codigo</th>
            <th>Descripcion</th>
            <th>Estado</th>
            <th>Acciones</th>
          </tr>
        </thead>
        <tbody class="searchable"
          @foreach($potreros as $potrero)
              <tr>
              <td>{{ $potrero->id }}</td>
              <td>{{ $potrero->cod_potrero }}</td>
              <td>{{ $potrero->descripcion }}</td>
              <td>{{$potrero->activo == 1 ? 'Activo' : 'Inactivo' }}</td>
              <td>
                <div class="btn-group">
                   <a href="{{ route('potreros.show', $potrero->id )}}" data-target="#mostrar" data-toggle="modal" class="btn btn-success">Ver</a>
                    <a href="#" class="btn btn-success dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
                    <ul class="dropdown-menu">
                    <li><a href="{{ route('potreros.edit', $potrero->id )}}" data-target="#editar" data-toggle="modal">Editar</a></li>
                    <li>{{ Form::open(array('url' => 'potreros/'.$potrero->id, 'method'=> 'delete')) }}
                      {{ Form::submit('Eliminar',  array('class' => "btn btn-default"))}}
                      {{ Form::close() }}</li>
                    <li class="divider"></li>
                    <li><a href="ganadopotrero/{{$potrero->id}}/potreros" data-target="#asociar" data-toggle="modal">Asociar ganado</a><li>
                    <li><a href="ganadopotrero/{{$potrero->id}}/ganados">Ver Ganados</a><li>
                    </ul>
                </div>
              </td> 
            </tr>
          @endforeach
        </tbody>
      </table>
      <button class="btn btn-primary" data-toggle="modal" data-target="#crear"><span class="glyphicon glyphicon-plus"></span> Agregar Potrero</button>
      <a href="{{ URL::to('ganadopotrero') }}"><button class="btn btn-warning"><span class="glyphicon glyphicon-new-window"></span> Ganado Potrero</button></a>
  @if(Session::has('message'))
      <div id="alerta" class="alert alert-{{ Session::get('class') }}">{{ Session::get('message')}}</div>
  @endif
<!--Modal crear -->
<div class="modal fade" id="crear" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header modal-header-default">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h1><i class="glyphicon glyphicon-check"></i> Crear Potrero</h1>
      </div>
        <div class="modal-body">
     {{Form::open(array('url' => 'potreros', 'method' => 'post'))}}
        <p>{{Form::text('cod_potrero', null, array('class' => 'form-control', 'placeholder' => 'Código de Potrero', 'required' => 'required'))}}</p>
        <p>{{Form::textarea('descripcion', null, array('class' => 'form-control', 'placeholder' => 'Descripción', 'rows' => 3, 'required' => 'required'))}}</textarea></p>
        <p><label for="activo">Estado:</label><select name="activo" id="activo" class="form-control">
          <option value="0">Inactivo</option>
            <option value="1">Activo</option>
            </select>
        </p>
      </div>
      <div class="modal-footer">
        <button type="submit" class="btn btn-warning" style="width: 30%"><span class="glyphicon glyphicon-ok-sign"></span> Crear</button>
                <button type="button" class="btn btn-default" style="width: 30%" data-dismiss="modal"><span ></span> Regresar</button>
    </form>
      </div>
    </div>
  </div>
</div>
 <!--Fin Modal crear -->
 <!--Modal editar -->
<div class="modal fade" id="editar" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header modal-header-default">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Editar Potrero</h4>
      </div>
        <div class="modal-body">
           
      </div>
      <div class="modal-footer">
        <input type="submit" value="Guardar" class="btn btn-success"><button class="btn btn-default" data-dismiss="modal">Regresar</button>
    </form>
      </div>
    </div>
  </div>
</div>
 <!--Fin Modal editar -->
 <!--Modal mostrar -->
<div class="modal fade" id="mostrar" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header-default">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Mostrar Potrero</h4>
      </div>
        <div class="modal-body">
           
      </div>
      <div class="modal-footer">
        <input type="submit" value="Guardar" class="btn btn-success"><button class="btn btn-default" data-dismiss="modal">Regresar</button>
    </form>
      </div>
    </div>
  </div>
</div>
 <!--Fin Modal mostrar -->
  <!---Modal ganadopotrero -->
 <div class="modal fade" id="asociar" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header-default">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Asociar Ganado a Potrero</h4>
      </div>
        <div class="modal-body">
           
      </div>
      <div class="modal-footer">
        <input type="submit" value="Guardar" class="btn btn-success"><button class="btn btn-default" data-dismiss="modal">Regresar</button>
    </form>
      </div>
    </div>
  </div>
</div>
<!--Fin Modal ganadopotrero -->
    </div>
  </div>
</div>
<script type="text/javascript">
    $(document).ready(function() {
    $('#potreros').dataTable({
      
      "dom": 'Rlfrtip',
        "language": {
            "sProcessing":     "Procesando...",
        "sLengthMenu":     "Mostrar _MENU_ registros",
        "sZeroRecords":    "No se encontraron resultados",
        "sEmptyTable":     "Ningún dato disponible en esta tabla",
        "sInfo":           "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
        "sInfoEmpty":      "Mostrando registros del 0 al 0 de un total de 0 registros",
        "sInfoFiltered":   "(filtrado de un total de _MAX_ registros)",
        "sInfoPostFix":    "",
        "sSearch":         "Buscar:",
        "sUrl":            "",
        "sInfoThousands":  ",",
        "sLoadingRecords": "Cargando...",
        "oPaginate": {
            "sFirst":    "Primero",
            "sLast":     "Último",
            "sNext":     "Siguiente",
            "sPrevious": "Anterior"
              },
              }
    } );
    var table = $('#potreros').DataTable();
 
  $('#filter').on( 'keyup', function () {
    table.search( this.value ).draw();
  } );
});
</script>
@stop